<%@ page import="com.food.dao.TaskDAO" %>
<%@ page import="com.food.model.Task" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>编辑任务</title>
    <style>
        body {
            font-family: "Arial", sans-serif;
            margin: 0;
            padding: 0;
            background: linear-gradient(to right, #81c784, #aed581);
            color: #333;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
        }

        .container {
            width: 90%;
            max-width: 600px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            padding: 30px;
        }

        h1 {
            text-align: center;
            color: #388e3c;
            margin-bottom: 20px;
        }

        label {
            display: block;
            font-weight: bold;
            margin-bottom: 5px;
            color: #495057;
        }

        input[type="number"],
        input[type="text"],
        select {
            width: 100%;
            padding: 10px;
            margin-bottom: 20px;
            border: 1px solid #ced4da;
            border-radius: 5px;
            font-size: 16px;
            color: #495057;
        }

        input:focus,
        select:focus {
            border-color: #388e3c;
            outline: none;
            box-shadow: 0 0 5px rgba(56, 142, 60, 0.5);
        }

        button {
            display: inline-block;
            background-color: #388e3c;
            color: white;
            border: none;
            border-radius: 5px;
            padding: 10px 20px;
            font-size: 16px;
            cursor: pointer;
            transition: background 0.3s;
        }

        button:hover {
            background: #66bb6a;
        }

        a {
            display: inline-block;
            margin-top: 10px;
            text-decoration: none;
            color: #388e3c;
            font-size: 14px;
            transition: color 0.3s;
        }

        a:hover {
            color: #66bb6a;
            text-decoration: underline;
        }

        .actions {
            text-align: center;
        }
    </style>
</head>
<body>
<%
    // 获取任务数据
    TaskDAO taskDAO = new TaskDAO();
    Task task = taskDAO.getTaskById(Integer.parseInt(request.getParameter("id")));
    request.setAttribute("task", task);
%>

<div class="container">
    <h1>编辑任务</h1>
    <form method="post" action="TaskServlet">
        <!-- 隐藏字段 -->
        <input type="hidden" name="action" value="edit" />
        <input type="hidden" name="id" value="${task.id}" />

        <!-- 订单ID -->
        <label for="ordersid">订单ID：</label>
        <input type="number" id="ordersid" name="ordersid" value="${task.ordersid}" required />

        <!-- 菜品名称 -->
        <label for="menuname">菜品名称：</label>
        <input type="text" id="menuname" name="menuname" value="${task.menuname}" required />

        <!-- 数量 -->
        <label for="quantity">数量：</label>
        <input type="number" id="quantity" name="quantity" value="${task.quantity}" min="1" required />

        <!-- 状态选择 -->
        <label for="status">状态：</label>
        <select id="status" name="status">
            <option value="1" ${task.status == 1 ? 'selected' : ''}>待做</option>
            <option value="2" ${task.status == 2 ? 'selected' : ''}>已做</option>
        </select>

        <!-- 操作按钮 -->
        <div class="actions">
            <button type="submit">保存</button>
            <a href="TaskServlet">返回</a>
        </div>
    </form>
</div>
</body>
</html>
